home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / tools / czesc_1 / easyprocess / source / launch / flushprocs.c < prev    next >
C/C++ Source or Header  |  1992-09-07  |  1KB  |  64 lines

  1. #include <arpbase.h>
  2. #include <arp_proto.h>
  3. #include "Launch.h"
  4. #include "LaunchPriv.h"
  5.  
  6.  
  7. /*
  8.  *    NAME
  9.  *        FlushProcesses -- free all children that are dead.
  10.  *
  11.  *    SYNOPSIS
  12.  *        FlushProcesses ()
  13.  *
  14.  *        void FlushProcesses (void);
  15.  *
  16.  *    DESCRIPTION
  17.  *        Scan the process pair list and if the parent is te current
  18.  *        process and the child is dead, it removes the pair and frees
  19.  *        the memory.
  20.  *
  21.  *        After the scan, we check if the current process is still a
  22.  *        parent.  If not, we free its signal bit.
  23.  *
  24.  *        We then check if the list is empty and free it.
  25.  *
  26.  *    INPUT
  27.  *        None.
  28.  *
  29.  *    OUTPUT
  30.  *        None.
  31.  *
  32.  *    HISTORY
  33.  *        1992/09/07    Pierre Baillargeon        Creation
  34.  */
  35.  
  36. void FlushProcesses (void)
  37. {
  38.     struct ProcPair *pp;
  39.     struct Process *Proc;
  40.     LONG Bit;
  41.  
  42.     Bit = -1L;
  43.     Proc = (struct Process *)FindTask (NULL);
  44.  
  45.     Forbid ();
  46.     if (NULL != ProcPairList)
  47.     {
  48.         for (pp = (struct ProcPair *)ProcPairList->lh_Head; pp->pp_Node.ln_Succ; pp = (struct ProcPair *)pp->pp_Node.ln_Succ)
  49.         {
  50.             if (Proc == pp->pp_Parent && NULL == pp->pp_ChildEntry)
  51.             {
  52.                 Bit = pp->pp_ParentBit;
  53.                 Remove (&pp->pp_Node);
  54.                 FreeMem (pp, sizeof (struct ProcPair));
  55.             }
  56.         }
  57.     }
  58.  
  59.     FreeParentSignal (Bit);
  60.     FreeProcPairList ();
  61.  
  62.     Permit ();
  63. }
  64.